package com.gf.exam.mapper;

import java.sql.ResultSet;
import java.sql.SQLException;

import org.springframework.jdbc.core.RowMapper;

import com.gf.base.type.Activity;
import com.gf.exam.model.Cell;
/**
 * 
 * @author zhuguifeng guifeng.net@gmail.com
 * @version 创建时间：2012-12-1 下午4:55:23
 */
public class CellMapper implements RowMapper<Cell> {

	private static final CellMapper CELL_MAPPER = new CellMapper();

	private static final String COLUME_ID = "id";
	private static final String COLUME_EXAMID = "examId";
	private static final String COLUME_NUMBER = "number";
	private static final String COLUME_HTMLCONTENT = "htmlContent";
	private static final String COLUME_ACTIVITY = "activity";

	public static CellMapper getMapper() {
		return CELL_MAPPER;
	}

	@Override
	public Cell mapRow(ResultSet set, int row) throws SQLException {
		Cell cell = new Cell();

		cell.setId(set.getLong(COLUME_ID));
		cell.setExamId(set.getLong(COLUME_EXAMID));
		cell.setNumber(set.getInt(COLUME_NUMBER));
		cell.setHtmlContent(set.getString(COLUME_HTMLCONTENT));
		cell.setActivity(Activity.valueOf(set.getString(COLUME_ACTIVITY)));

		return cell;
	}

}
